#include <linux/module.h>
#include <linux/miscdevice.h>
#include <linux/delay.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/capability.h>
#include <linux/init.h>
#include <linux/mutex.h>
#include <asm/mach-types.h>
#include <asm/uaccess.h>
#include <asm/therm.h>

// #include <linux/init.h>
// #include <linux/tty.h>
// #include <linux/device.h>
// #include <linux/export.h>
// #include <linux/types.h>

// #include <linux/module.h>
// #include <linux/export.h>

static int major;

static int hello_open (struct inode *node, struct file *filp)
{
	printk("hello_open\n");
	printk("%s %s %d\n",__FILE__, __FUNCTION__, __LINE__);
	return 0;
}

static ssize_t hello_read (struct file *filp, char  *buf, size_t size, loff_t *offset)
{
	printk("hello_read\n");
	return size;
}

static ssize_t hello_write (struct file *filp, const char  *buf, size_t size, loff_t *offset)
{
	printk("hello_write\n");
	return size;
}

static int hello_release (struct inode *node, struct file *filp)
{
	printk("hello_release\n");
	return 0;
}

/*1.定义 file_operations 结构体*/
static const struct file_operations hello_drv = {
    .owner 		= THIS_MODULE,
	.read		= hello_read,
	.write		= hello_write,
	.open		= hello_open,
	.release    = hello_release,
};


/*2.register_chrdev*/

/*3.入口函数*/
static int hello_init(void)
{
	//设备号
	major = register_chrdev(0,"hello_drv",&hello_drv);
	return 0;
}

/*4.退出函数*/
static void hello_exit(void)
{
	unregister_chrdev(0,"hello_drv");
}	

module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
